<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>兼职招聘系统-后台登陆</title>
<link rel="stylesheet" href="css/login.css">
<link rel="short icon" href="images/logo.png" type="image/x-icon">
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
	<div id="login_top">
		<div id="welcome">欢迎使用兼职招聘系统后台管理系统</div>
		<div id="back">
			<a href="../../index_jober.html">返回首页</a>&nbsp;&nbsp; | &nbsp;&nbsp; <a href="#">帮助</a>
		</div>
	</div>
<div id="app">		
	<div id="login_center">
		<div id="login_area">
			<div id="login_form">
				<form action="" method="post" id="myform">
					<div id="login_tip">
						用户登录&nbsp;&nbsp;UserLogin
					</div>
					<div>
						<input type="text" class="username" v-model="aname" autofocus="autofocus" @blur="checkInfo(0)" placeholder="请输入账号..."></br>
						<span v-if="status[0]" style="color:red;">账号格式不正确...</span>
					</div>
					<div>
						<input type="password" class="pwd" v-model="pwd" @blur="checkInfo(1)" placeholder="请输入密码..."></br>
						<span v-if="status[1]" style="color:red;">密码格式不正确...</span>
					</div>
					<div id="btn_area">
						<input type="button" id="sub_btn" @click="login" value="登录">
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
	<div id="login_bottom">
		<label style="color: #FFF"><a class="copy"
			href="">沈阳xxxxxx学院  </a>&copy; 版权所有</label>
	</div>
</body>

<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript" src="../js/axios.js"></script>
<script type="text/javascript" src="../js/qs.js"></script>
<script type="text/javascript">
	let vm = new Vue({
		el:"#app",
		data: {
			aname: "",
			pwd: "",
			status: [false,false]
		},
		methods: {
			checkInfo: function(flag){
				let correct = false;
				if(flag == 0){
					let reg1 = /^1(3|4|5|6|7|8|9)\d{9}$/;
					let reg2 = /^[\u4e00-\u9fff\w]{2,16}$/;
					if( reg1.test(this.aname) || reg2.test(this.aname)){
						correct = false;
					}else{
						correct = true;
					}
				}else if(flag == 1){
					let reg = /^[0-9a-zA-Z_,\.]{4,16}$/;
					if(reg.test(this.pwd)){
						correct = false;
					}else {
						correct = true;
					}
				}
			Vue.set(vm.status,flag,correct);
		},
		login: function() {
			this.checkInfo(0);
			this.checkInfo(1);
			if ($.inArray(true, this, status) >= 0) {//说明在集合中找到了true,说明还有文本框猃证没有通过
				return;
			}
			//aname=this.aname&pwd=this.pwd
			axios.post("../login/adminLogin", qs.stringify({aname:this.aname, pwd:this.pwd})).then(result =>{
				if (result.data.code == 200) {
					location.href="manager/index.html";
				} else if (result.data.code == 500) {
					alert("账号或密码错误，请确认后重新输入...")
				}
			})
		}
	}
})
</script>

</html>